using Unity.Entities;
using UnityEngine;

namespace Tanks.Execute
{
    public struct TurretRotation : IComponentData
    {
    }

    public struct TankMovement : IComponentData
    {
    }

    public struct TurretShooting : IComponentData
    {
    }
    
    public struct CannonBall : IComponentData
    {
    }

    public struct TankSpawning : IComponentData
    {
    }

    public struct SafeZone : IComponentData
    {
    }

    public struct Camera : IComponentData
    {
    }
    
    public class ExecuteAuthoring : MonoBehaviour
    {
        [Header("Step 2 炮塔旋转")] 
        public bool TurretRotation;
        [Header("Step 3 坦克移动")] 
        public bool TankMovement;
        [Header("Step 4 炮塔射击")]
        public bool TurretShooting;
        [Header("Step 5 炮弹飞行")]
        public bool CannonBall;
        [Header("Step 6 生成坦克")]
        public bool TankSpawning;
        [Header("Step 7 安全区域")]
        public bool SafeZone;
        [Header("Step 8 摄像机切换")]
        public bool Camera;
        
        class Baker : Baker<ExecuteAuthoring>
        {
            public override void Bake(ExecuteAuthoring authoring)
            {
                var entity = GetEntity(TransformUsageFlags.None);
                if (authoring.TurretRotation) AddComponent(entity, new TurretRotation());
                if (authoring.TankMovement) AddComponent(entity, new TankMovement());
                if (authoring.TurretShooting) AddComponent(entity, new TurretShooting());
                if (authoring.CannonBall) AddComponent(entity, new CannonBall());
                if (authoring.TankSpawning) AddComponent(entity, new TankSpawning());
                if (authoring.SafeZone) AddComponent(entity, new SafeZone());
                if (authoring.Camera) AddComponent(entity, new Camera());
            }
        }
    }
}